import axios from "axios"

//   Blog音乐故事

// 发布音乐故事
async function UploadBlog(BlogUploadDTO){
  var result
  await axios({
      baseURL: 'api/blog/uploadblog',
      headers: {'Content-Type': 'application/json;charset=UTF-8' },
      data: BlogUploadDTO,
      method: 'post',
  }).then(res => {
      result=res.data
      console.log(result);
  })
  return result
}
  //    分页获取blog故事（根据浏览量倒序排序）
  // 没写
  async function GetAllBlog(pageNumber,pageSize){
    var result
    await axios({
        baseURL: 'api/blog/allblog/'+pageNumber+'/'+pageSize,
        method: 'get',
    }).then(res => {
        result=res.data
        console.log(result);
    })
    return result
  }


// 查看blog故事详情
async function GetAllInfoById(blogId){
  var result
  await axios({
      baseURL: 'api/blog/allinfo?blogId='+blogId,
      method: 'get',
  }).then(res => {
      result=res.data
      console.log(result);
  })
  return result
}

// //    根据音乐id获取blog的音乐故事（浏览量倒序排序）
async function GetAllByMusicId(musicId,pageNumber,pageSize){
  var result
  await axios({
      baseURL: 'api/blog/bymusicid//'+pageNumber+'/'+pageSize+'?musicId='+musicId,
      method: 'get',
  }).then(res => {
      result=res.data
      console.log(result);
  })
  return result
}

// //    根据用户id获取blog的音乐故事（浏览量倒序排序）
async function GetAllByUserId(userId,pageNumber,pageSize){
  var result
  await axios({
      baseURL: 'api/blog/byuserid//'+pageNumber+'/'+pageSize+'?userId='+userId,
      method: 'get',
  }).then(res => {
      result=res.data
      console.log(result);
  })
  return result
}



// 获取blogimgUrlList
async function GetBlogImgList(blogId){
  var result
  await axios({
      baseURL: 'api/blog/blogimglist?blogId='+blogId,
      method: 'get',
  }).then(res => {
      result=res.data
      console.log(result);
  })
  return result
}



  // 添加故事浏览量




export default {
  name: 'BlogAPI',

  UploadBlog,
  GetAllBlog,
  GetAllInfoById,
  GetAllByMusicId,
  GetBlogImgList,
  GetAllByUserId
}
